"""
移除 codesign上的icon的 指定宽度和高度
"""
import re
from icon_r_util import get_icon_list_from_remote_in_codesign, update_icon_in_codesign, codesign_config
from bs4 import BeautifulSoup


def remove_height_width(icon):
    # 读取svg字符串
    original_svg = icon['original_svg']
    # 构建svg标签
    svg = BeautifulSoup(original_svg, 'lxml')
    # 移除svg标签上的height width
    svg.svg.attrs.pop('height', None)
    svg.svg.attrs.pop('width', None)
    # 保存svg标签
    svg = svg.svg
    # 更新icon
    

    update_dict = {
        'original_svg': original_svg,
        'svg': str(svg)
    }
    update_icon_in_codesign(icon['id'], update_dict)


if __name__ == '__main__':

    icon_list = get_icon_list_from_remote_in_codesign()
    for icon in icon_list:
        remove_height_width(icon)
